/***********************************************************************
 * Module:  Npc.java
 * Author:  luohaoyang
 * Purpose: Defines the Class NPC
 ***********************************************************************/

package com.afteryuan.engine.model;
                
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.Date;

import com.afteryuan.dao.BaseObject;

@Entity
@Table(name = "T_CARTOONDATA")
public class CartoonData extends BaseObject {

	private String id;

    /**
     * 方向,8个方向
     */
    private Integer direct;

    /**
     * 动作类型,走,跑,跳等等
     */
    private Integer pose;

    /**
     * 当前帧数(第几帧)
     */
    private Integer frameNumber;
    /**
     * 总帧数
     */
    private Integer frameCount;

    /**
     * 初始x
     */
    private Integer initX;
    /**
     * 初始y
     */
    private Integer initY;
    /**
     * 初始宽
     */
    private Integer width;
    /**
     * 初始高
     */
    private Integer height;
    private Long createTime;
    private byte[] bitmapData;

    private Cartoon cartoon;

    public CartoonData() {
        setCreateTime(new Date().getTime());
    }

    public CartoonData(String id) {
        this();
        this.id = id;
    }
    
	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getDirect() {
        return direct;
    }

    public void setDirect(Integer direct) {
        this.direct = direct;
    }

    public Integer getPose() {
        return pose;
    }

    public void setPose(Integer pose) {
        this.pose = pose;
    }

    public Integer getFrameNumber() {
        return frameNumber;
    }

    public void setFrameNumber(Integer frameNumber) {
        this.frameNumber = frameNumber;
    }

    public Integer getFrameCount() {
        return frameCount;
    }

    public void setFrameCount(Integer frameCount) {
        this.frameCount = frameCount;
    }

    public Integer getInitX() {
        return initX;
    }

    public void setInitX(Integer initX) {
        this.initX = initX;
    }

    public Integer getInitY() {
        return initY;
    }

    public void setInitY(Integer initY) {
        this.initY = initY;
    }

    public Integer getWidth() {
        return width;
    }

    public void setWidth(Integer width) {
        this.width = width;
    }

    public Integer getHeight() {
        return height;
    }

    public void setHeight(Integer height) {
        this.height = height;
    }
    @Column(updatable = false)
    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public byte[] getBitmapData() {
        return bitmapData;
    }

    public void setBitmapData(byte[] bitmapData) {
        this.bitmapData = bitmapData;
    }

    @ManyToOne
    @JoinColumn(name="CARTOON_ID")
    public Cartoon getCartoon() {
        return cartoon;
    }

    public void setCartoon(Cartoon cartoon) {
        this.cartoon = cartoon;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CartoonData that = (CartoonData) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return id != null ? id.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "CartoonData{" +
                "height=" + height +
                ", width=" + width +
                ", initY=" + initY +
                ", initX=" + initX +
                ", id='" + id + '\'' +
                '}';
    }
}